package org.spring.aop;

import java.util.Objects;

/**
 * TargetSource 接口的默认实现
 *
 * @author 李坤
 * @date 2022/4/18 10:56
 */
public class SingletonTargetSource implements TargetSource {

    /**
     * 被代理对象
     */
    private final Object target;

    public SingletonTargetSource(Object target) {
        this.target = target;
    }

    @Override
    public boolean isStatic() {
        return false;
    }

    @Override
    public Class<?> getTargetClass() {
        return Objects.nonNull(target) ? target.getClass() : null;
    }

    @Override
    public Object getTarget() throws Exception {
        return target;
    }

    @Override
    public void releaseTarget(Object target) throws Exception {

    }

}
